package com.darling.danotebackend.model.enums;

import cn.hutool.core.util.ObjUtil;
import com.darling.danotebackend.constant.FileConstant;
import lombok.Getter;

/**
 * 空间等级枚举类
 *
 * @author wzd
 */
@Getter
public enum SpaceLevelEnum {

    COMMON("普通版", 0, 50, FileConstant.mbToBytes(100)),
    PROFESSIONAL("专业版", 1, 100, FileConstant.mbToBytes(1000)),
    FLAGSHIP("旗舰版", 2, 1000, FileConstant.mbToBytes(10000));

    private final String text;

    private final int value;

    private final long maxCount;

    private final long maxSize;


    /**
     * @param text     文本
     * @param value    值
     * @param maxSize  最大图片总大小
     * @param maxCount 最大图片总数量
     */
    SpaceLevelEnum(String text, int value, long maxCount, long maxSize) {
        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }

    /**
     * 根据 value 获取枚举
     */
    public static SpaceLevelEnum getEnumByValue(Integer value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        for (SpaceLevelEnum spaceLevelEnum : SpaceLevelEnum.values()) {
            if (spaceLevelEnum.value == value) {
                return spaceLevelEnum;
            }
        }
        return null;
    }


}

